<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
test(() => {
    assert_selection(
        '|<style>* {display: list-item}</style>',
        selection => {
            let doc = selection.document;
            doc.designMode = 'on';
            // Insert an element into STYLE to cause crash
            element = doc.createElement('div');
            element.textContent = 'foo';
            var style = doc.querySelector('style');
            style.insertBefore(element, style.firstChild);
            doc.documentElement.replaceChild(style, doc.body);
            doc.execCommand('selectAll');
            doc.execCommand('JustifyFull');
        },
        [
            '<html>',
            '<head style="text-align: justify;"></head>',
            '<style>',
            '<div style="text-align: justify;">foo</div>',
            '<div><br></div>',
            '<br>',
            '</style>',
            '</html>'
        ].join(''));
}, 'justyFull should not crash without BODY');
</script>
